home *** CD-ROM | disk | FTP | other *** search
/ Windows 95 API Bible / Windows 95 API Bible 3 Disc Set.iso / Win32 API Bible Book 1 of 3.iso / chapte22 / ex17.c < prev    next >
C/C++ Source or Header  |  1995-05-27  |  1KB  |  38 lines

  1. #include <genstub.c>
  2.  
  3. LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  4. {
  5.    switch (uMsg)
  6.    {
  7.          case WM_COMMAND:
  8.                switch ( LOWORD( wParam )  )
  9.                {
  10.                      case IDM_EXIT:
  11.                            DestroyWindow( hWnd );
  12.                      break;
  13.                }
  14.                break;
  15.          case WM_KEYDOWN:
  16.          {
  17.                BYTE keys[256];
  18.                TCHAR szBuffer1[32];
  19.                TCHAR szBuffer2[32];
  20.                DWORD dwReturnedValue;
  21.  
  22.                GetKeyboardState( keys );
  23.                wsprintf( szBuffer1, "ToAscii Returned %d Bytes.",
  24.                          ToAscii( wParam, (lParam >> 16) && 0xFF,
  25.                                   keys, &dwReturnedValue, 0 ) );
  26.                wsprintf( szBuffer2, "[%c] was the character returned.",
  27.                          (TCHAR) dwReturnedValue & 0xFF );
  28.                MessageBox( hWnd, szBuffer2, szBuffer1, MB_OK );
  29.          }
  30.          break;
  31.          case WM_DESTROY:
  32.                PostQuitMessage( 0 );
  33.                break;
  34.          default:
  35.                return (DefWindowProc(hWnd, uMsg, wParam, lParam));
  36.    }
  37.    return (NULL);
  38. }